﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using StructureMap.Configuration.DSL;
using StructureMap;
using KingSite.Shop.Core.Service;
using KingSite.Shop.Service;
using KingSite.Shop.Core.Repository;
using KingSite.Shop.Repository;

namespace KingSite.Shop.WebPortal {
    public static class Bootstrapper {

        public static void ConfigureStructureMap() {
            StructureMapConfiguration.AddRegistry(new StorefrontRegistry());
        }
    }

    public class StorefrontRegistry : Registry {
        protected override void configure() {

            #region Service
            ForRequestedType<ICartDetailService>()
                .TheDefaultIsConcreteType<CartDetailService>();

            ForRequestedType<ICartService>()
                .TheDefaultIsConcreteType<CartService>();

            ForRequestedType<ICategoryService>()
                .TheDefaultIsConcreteType<CategoryService>();

            ForRequestedType<ICustomerService>()
                .TheDefaultIsConcreteType<CustomerService>();

            ForRequestedType<IGoodsEvaluationReplyService>()
                .TheDefaultIsConcreteType<GoodsEvaluationReplyService>();

            ForRequestedType<IGoodsEvaluationService>()
               .TheDefaultIsConcreteType<GoodsEvaluationService>();

            ForRequestedType<IGoodsManyAttributeService>()
               .TheDefaultIsConcreteType<GoodsManyAttributeService>();

            ForRequestedType<IGoodsService>()
               .TheDefaultIsConcreteType<GoodsService>();

            ForRequestedType<IGoodsSingleAttributeService>()
               .TheDefaultIsConcreteType<GoodsSingleAttributeService>();

            ForRequestedType<IIndexRecommendService>()
               .TheDefaultIsConcreteType<IndexRecommendService>();

            ForRequestedType<INewsService>()
             .TheDefaultIsConcreteType<NewsService>();

            ForRequestedType<IRecommendTypeService>()
              .TheDefaultIsConcreteType<RecommendTypeService>();

            ForRequestedType<ISkuService>()
              .TheDefaultIsConcreteType<SkuService>();
            #endregion

            #region Reposityory
            ForRequestedType<ICartDetailRepository>()
             .TheDefaultIsConcreteType<CartDetailRepository>();

            ForRequestedType<ICartRepository>()
             .TheDefaultIsConcreteType<CartRepository>();

            ForRequestedType<ICategoryRepository>()
               .TheDefaultIsConcreteType<CategoryRepository>();

            ForRequestedType<ICustomerRepository>()
               .TheDefaultIsConcreteType<CustomerRepository>();

            ForRequestedType<IGoodsEvaluationReplyRepository>()
              .TheDefaultIsConcreteType<GoodsEvaluationReplyRepository>();

            ForRequestedType<IGoodsEvaluationRepository>()
              .TheDefaultIsConcreteType<GoodsEvaluationRepository>();

            ForRequestedType<IGoodsManyAttributeRepository>()
              .TheDefaultIsConcreteType<GoodsManyAttributeRepository>();

            ForRequestedType<IGoodsRepository>()
              .TheDefaultIsConcreteType<GoodsRepository>();

            ForRequestedType<IGoodsSingleAttributeRepository>()
              .TheDefaultIsConcreteType<GoodsSingleAttributeRepository>();

            ForRequestedType<IIndexRecommendRepository>()
              .TheDefaultIsConcreteType<IndexRecommendRepository>();

            ForRequestedType<INewsRepository>()
              .TheDefaultIsConcreteType<NewsRepository>();

            ForRequestedType<IRecommendTypeRepository>()
              .TheDefaultIsConcreteType<RecommendTypeRepository>();

            ForRequestedType<ISkuRepository>()
              .TheDefaultIsConcreteType<SkuRepository>();

            #endregion

        }
    }
}
